package com.zxn.rv;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.zxn.rv.event.UserBean;
import com.zxn.rv.utils.UserInfoManager;
import com.zxn.rv.utils.ViewCenterUtils;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * @author: njb
 * @date: 2020/2/23 0023 20:50
 * @desc:
 */
public class SecondActivity extends AppCompatActivity {
    private LinearLayout constraintLayout;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        initView();
        EventBus.getDefault().register(this);
    }

    private void initView() {
        constraintLayout = findViewById(R.id.cl_input);
        if (getIntent() != null && getIntent().getExtras() != null) {
            ViewCenterUtils.setActivityStartAnim(this, constraintLayout, getIntent());
        }
        constraintLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SecondActivity.this,SaveFileActivity.class));
            }
        });
       Log.d("-----getSportData------",UserInfoManager.getSportKM()) ;
    }

    /**
     * 订阅者处理粘性事件
     * @param userBean 接手过来的实体类
     */
    @Subscribe(threadMode = ThreadMode.POSTING,sticky = true)
    public void ononMoonStickyEvent(UserBean userBean){
        Log.d("--userBeanData--",userBean.getUsername() + "/ " +userBean.getPassword() + " / "+
                userBean.getPhone()+ " / " + userBean.getNickname());

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
